package com.tg.push;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.tg.appcommon.android.TGLog;

public abstract class TGCorePushReceiver extends BroadcastReceiver implements TGPushCallback {

    private static final String TAG = "TGCorePushReceiverTag";

    @Override
    public void onReceive(Context context, Intent intent) {

        TGLog.i(TAG, "[TGCorePushReceiver.onReceive] intent = " + intent);

        String action = intent.getAction();
        String extraMap = intent.getStringExtra(PushConstants.KEY_EXTRA);
        String title = intent.getStringExtra(PushConstants.KEY_TITLE);
        String summary = intent.getStringExtra(PushConstants.KEY_DESC);

        TGLog.i(TAG, "[TGCorePushReceiver.onReceive] action = " + action);
        TGLog.i(TAG, "[TGCorePushReceiver.onReceive] extraMap = " + extraMap);
        TGLog.i(TAG, "[TGCorePushReceiver.onReceive] title = " + title);
        TGLog.i(TAG, "[TGCorePushReceiver.onReceive] summary = " + summary);

        TGLog.i(TAG, "[TGCorePushReceiver.onReceive]  =================== ");
        TGLog.i(TAG, "[TGCorePushReceiver.onReceive]  =================== ");
        TGLog.i(TAG, "[TGCorePushReceiver.onReceive]  =================== ");

        if (PushConstants.ACIONT_NOTIFICATION_OPENED.equalsIgnoreCase(action)){
            onNotificationMessageOpened(context,title,summary,extraMap);
        } else if (PushConstants.ACIONT_NOTIFICATION_REMOVED.equalsIgnoreCase(action)){
            onNotificationMessageOpened(context,title,summary,extraMap);
        } else if (PushConstants.ACIONT_RECEIVE.equalsIgnoreCase(action)){
            onNotificationMessageArrived(context,title,summary,extraMap);
            Log.d("TGPushReceiver","onReceive2");
        }
    }

}
